package org.syntaxlisp.core.element;

public enum SyntaxLispElementType {

    // Inductive Type
    ALTERNATIVE,
    SEQ_CONNECT,
    SIMPLIFY_REPEAT,
    NOT_OR,

    // Base Type
    STRING,
    SCOPE,
    CHARACTER,
    REF,
    NUMBER,
    BASE,

    // 中间类型
    SUBTRACT_SCOPE,
    AMBIGUOUS_OR,
    UNION_SCOPE,
    IMP,
    ZERO_OR_MORE,
    ZERO_OR_ONE,
    ONE_OR_MORE,
    REPEAT,
    ZERO_OR_MORE_GREEDY,
    ZERO_OR_ONE_GREEDY,
    ONE_OR_MORE_GREEDY,
    REPEAT_GREEDY;

    /**
     * element 是否为当前类型
     * @param element element
     * @return element 是否为当前类型
     */
    public boolean isTypeMatch(SyntaxLispElement element) {
        return this == element.getType();
    }

    public static boolean isNoTerminalType (SyntaxLispElementType type) {
        return type == ALTERNATIVE
               || type == SEQ_CONNECT
               || type == SIMPLIFY_REPEAT
               || type == NOT_OR

               || type == AMBIGUOUS_OR
               || type == SUBTRACT_SCOPE
               || type == UNION_SCOPE

               || type == ZERO_OR_MORE_GREEDY
               || type == ZERO_OR_ONE_GREEDY
               || type == ONE_OR_MORE_GREEDY
               || type == REPEAT_GREEDY
               || type == ZERO_OR_MORE
                || type == ZERO_OR_ONE
                || type == ONE_OR_MORE
                || type == REPEAT;
    }

    public static boolean isNoTerminalType (SyntaxLispElement element) {
        return isNoTerminalType(element.getType());
    }
    public static boolean isBaseType (SyntaxLispElement element) {
        return isBaseType(element.getType());
    }

    public static boolean isBaseType (SyntaxLispElementType type) {
        return type == STRING
               || type == SCOPE
               || type == CHARACTER
               || type == REF
               || type == NUMBER
               || type == BASE;
    }
}